package api

import (
	"context"
	"goods_rpc/internal/server"
	pb "goods_rpc/proto/goods"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)

type GoodsServer struct {
	pb.UnimplementedGoodsServerServer
}

func (s *GoodsServer) CreateGoods(_ context.Context, req *pb.CreateGoodsRequest) (resp *pb.CreateGoodsResponse, err error) {
	goods, err := server.CreateGoods(req)
	if err != nil {
		return nil, status.Errorf(codes.Unimplemented, "method CreateGoods not implemented")
	}
	return &pb.CreateGoodsResponse{GoodsID: int64(goods.ID)}, nil
}
